package com.example.gkw.dagger2test;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.example.gkw.dagger2test.demo.Car;
import com.example.gkw.dagger2test.demo3.MCar;
import com.example.gkw.dagger2test.demo4.ACar;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.btn1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Car().getEngine().run();
            }
        });
        findViewById(R.id.btn2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new com.example.gkw.dagger2test.demo2.Car().getEngine().run();
            }
        });

        findViewById(R.id.btn3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MCar mCar = new MCar();
                mCar.getEngineA().run();
                mCar.getEngineB().run();
            }
        });

        findViewById(R.id.btn4).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ACar mCar = new ACar();
                mCar.getEngineA().run();
                mCar.getEngineB().run();
            }
        });
    }
}
